package com.example.cachedemo.service;

import java.util.HashMap;

public class SimpleCache {
    static HashMap cache = new HashMap();

    public static boolean setCache(String key, Object value) {
        try {
            cache.put(key, value);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static Object getCache(String key) {
        if (cache.containsKey(key)) {
            return cache.get(key);
        }
        return null;
    }

    public static boolean deleteCache(String key) {
        if (cache.containsKey(key)) {
            try {
                cache.remove(key);
                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
        return true;
    }
}